<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::any('wechat',   'WechatController@serve');
Route::any('create-menu',   'WechatController@createMenu');
Route::get('test','IndexController@test');

// 预约模块
Route::prefix('booking')->group(function(){
	Route::get('index',    'BookingController@index');
	Route::get('send-sms', 'BookingController@sendMsg');
	Route::middleware(['wechat.oauth'])->group(function(){
		Route::any('save',  'BookingController@save');
	});
});



Route::get('logout',   'LoginController@logOut');

// Route::get('reg',	   'RegisterController@index');
// Route::any('regdo',	   'RegisterController@regdo');
// Route::get('sendmsg',  'IndexController@sendmsg');
// Route::get('getarea',  'IndexController@getArea');
//Route::get('push-msg' ,'IndexController@pushMsg');
Route::middleware(['wechat.oauth'])->group(function(){
	Route::get('login',    'LoginController@login');
 	Route::any('logindo', 'LoginController@loginDo');
});





/**
 * 后端路由
 */
Route::prefix('zadmin')->namespace('Admin')->group(function(){
	Route::middleware('checkAdmin')->group(function(){
		Route::resource('system','SystemController');
		

		// 预约信息
		Route::get('bookings/export', 'BookingController@export');
		Route::resource('bookings',   'BookingController');
		
		// 自定义表单
		Route::resource('fields',     'FieldController');
		Route::resource('admins',     'AdminController');
		Route::resource('users',      'UserController');
		Route::resource('roles',      'RoleController');
		Route::resource('menus',      'MenuController');
		Route::resource('depart',     'DepartController');
		Route::resource('services',   'ServiceController');
		Route::get('menus/permission/{menu_id}', 'MenuController@menuPermission');
		Route::resource('permissions', 'PermissionController');	
		Route::resource('category',   'CategoryController');		

		

		
		Route::post('save-wxusers','UserController@saveWxuser');
		

		Route::prefix('wechat')->group(function(){
			Route::get('users',      'UserController@wechatUsers');
			

			
			Route::get('msgtpl',     'MsgtplController@index');
			Route::get('msgtpl-show/{tpl_key}','MsgtplController@show');
			Route::get('msgtpl-edit/{tpl_key}','MsgtplController@edit');
			Route::post('msgtpl-save',         'MsgtplController@save');
			Route::get('msgtpl-del/{tpl_key}', 'MsgtplController@del');
			Route::get('msgtpl-import','MsgtplController@import');
			Route::get('msgtpl-all','MsgtplController@all');
			Route::get('menu','WxMenuController@index');
		
		});


		
		

		// 统计报表
		Route::prefix('census')->group(function(){
			Route::any('worker-count','CensusController@workerCount');
			Route::any('worker-count-export','CensusController@workerCountExport');
		});
		
	
		//后台首页
		Route::get('/',		   'IndexController@index');
		
	});
		Route::get('login',    'LoginController@login');
		Route::post('logindo', 'LoginController@loginDo');
		Route::get('logout',   'LoginController@logOut');
		
	
});






